<?php $title="hello";
include('getData.php');
include('Library.php');
$getXHTML=new xmlLibrary();
$getXHTML->CreateXHTML('http://www.vnexpress.net','vnxpress.xhtml');
$page_title="Lấy tin theo các trang web";
global $db;
$sql="select xpathTithle,xpathHead,xpathContent,xpathImage from xpath";
$result=$db->sql_query($sql);
$numfields = mysql_num_rows($result);
$arr=array();$dem=-1;$a=array();
while($row=mysql_fetch_array($result) and $i<$numfields)
{
	$a[$i]['title']=load("//".$row[0]);
	$a[$i]['head']=load("//".$row[1]);
	$a[$i]['content']=load("//".$row[2]);
	$a[$i]['image']=load("//".$row[3]);
	$i++;
}
$contents='
<script type="text/javascript">
	function getDetails(title,head,content,image)
	{
		document.getElementById("title").value=title;
		document.getElementById("head").value=head;
		document.getElementById("content").value=content;
		document.getElementById("image").value=image;
	}
</script>
<script type="text/javascript" src="'.NV_BASE_SITEURL.'/modules/'.$module_name.'/js/jquery-1.4.1.min.js">
</script>
<form action="index.php?nv=getnews" method="post" id="form1" name="form1"><table width="100%" border="0" cellspacing="0" cellpadding="0">
  <tr>
    <td width="5%">Url</td>
    <td width="20%"><label for="url"></label>
      <select name="url" id="url">
	  <option value="vnexpress.net">http://vnexpress.net</option>
      </select></td>
    <td width="60%"><input type="submit" name="button" id="button" value="Lấy tin" /></td>
  </tr>
  <br />
</table>

<table width="100%" border="1" cellspacing="0" cellpadding="0">
  <tr>
    <td>STT</td>
    <td>Tiêu đề</td>
    <td>Tóm tắt</td>
    <td>Nội dung</td>
    <td>Ảnh</td>
    <td>&nbsp;</td>
  </tr>';
  for($i=0;$i<count($a);$i++)
  {
	  $contents.='
  <tr>
    <td>'.($i+1).'</td>
    <td>'.$a[$i]['title'].'</td>
    <td>'.$a[$i]['head'].'</td>
    <td>'.substr($a[$i]['content'],0,15).'</td>
    <td>'.$a[$i]['image'].'</td>
    <td><a href="#" onclick="$(\'#form1\').hide(\'fast\');$(\'#form2\').show();getDetails(\''.$a[$i]['title'].'\',\''.$a[$i]['head'].'\',\''.$a[$i]['content'].'\',\''.$a[$i]['image'].'\');" >chi tiết</a></td>
  </tr>';
  }
 $contents.='
</table>
<div name="hello" id="div1"> xin chào</div>
</form>

<form action="index.php?nv=getnews" method="post" name="form2" id="form2">
  <table width="100%" border="0" cellspacing="0" cellpadding="0">
    <tr>
      <td colspan="2">Tiêu đề :<br /><input name="title" id="title" type="text" size="150"></input></td>
    </tr>
    <tr>
       <td colspan="2">Tóm tắt :<br /><textarea name="head" id="head" cols="" rows="5" style="width:100%"></textarea>
       </td>
    </tr>
    <tr>
       <td colspan="2">Nội dung :<br />
      <textarea name="content" id="content"  cols="" rows="10" style="width:100%"></textarea>
      </td>
     </tr>
     <tr>
      <td colspan="2">Ảnh: </td>
    </tr>
    <tr>
      <td align="center"><input type="button" name="save" id="save" value="Lưu bài viết" onclick="$(\'#form1\').show();$(\'#form2\').hide(\'fast\');" /></td>
      <td align="center"><input type="submit" name="save_edit" id="save_edit" value="Lưu vào chỉnh sửa" /></td>
    </tr>
  </table>
</form>
<script type="text/javascript">
$("#form2").hide("fast");
</script>
';
?>
<?php
	include ( NV_ROOTDIR . "/includes/header.php" );
	echo nv_admin_theme($contents);
	include ( NV_ROOTDIR . "/includes/footer.php" );

?>